package com.yugao.fintech.vctgone.admin.converter;

import com.yugao.fintech.vctgone.admin.pojo.dto.DeptDTO;
import com.yugao.fintech.vctgone.admin.pojo.po.SysDept;
import com.yugao.fintech.vctgone.admin.pojo.vo.DeptTreeVO;
import com.yugao.fintech.vctgone.web.vo.SelectTreeVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

@Mapper(componentModel = "spring")
public interface DeptConverter {
    /**
     * SysDept -> DeptTreeVO
     *
     * @param sysDept SysDept
     * @return DeptTreeVO
     */
    @Mapping(target = "children", ignore = true)
    DeptTreeVO sysDeptToDeptTreeVO(SysDept sysDept);

    /**
     * DeptDTO -> SysDept
     *
     * @param dto DeptDTO
     * @return SysDept
     */
    SysDept deptDtoToSysDept(DeptDTO dto);

    /**
     * SysDept -> SelectTreeVO
     *
     * @param sysDept SysDept
     * @return SelectTreeVO
     */
    @Mapping(source = "id", target = "value")
    @Mapping(source = "name", target = "label")
    @Mapping(target = "children", ignore = true)
    SelectTreeVO sysDeptToSelectTreeVo(SysDept sysDept);
}
